var Schema = require("jugglingdb").Schema;

var cfg = {
    dialect: "mysql",
    database: "cc-deal-test",
    host : "aliyun327.kuick.cn",
    port : 53306,
    user : "root",
    password : "Dwed123xxxDxx23@#",
    collation : "utf8mb4_general_ci",
    minPoolSize: 1,
    maxPoolSize: 3,
    ormConnectionLimit: 3
}

var schema = new Schema(cfg.dialect,
    {
        host: cfg.host,
        port: cfg.port,
        database: cfg.database,
        username: cfg.user,
        password: cfg.password,
        collation: cfg.collation,
        debug: false
    }
);

schema.define('AppSetting', {
    id: {type : String, dataType: 'varchar', length: 100, primaryKey : true}, //记录唯一标识：使用uuid
    appId: {type : String, dataType: 'varchar', length: 100}, //应用唯一标识
    key: {type : String, dataType: 'varchar', length: 100},
    type : {type : String, dataType: 'varchar', length: 100},
    value: {type : String, dataType: 'varchar', length: 100},
    defaultValue: {type : String, dataType: 'varchar', length: 100},
    createdAt: { type: Date, dataType: 'datetime', default:function () { return new Date;} },
    updatedAt: { type: Date, dataType: 'datetime', default:function () { return new Date;} }
},{
    table:'app_setting'
});

var AppSetting = schema.models.AppSetting;

var option = {
    id: "test-create-return-value",
	appId: "appId",
	key: "key",
	type: "type",
	value: "value",
	defaultValue: "defaultValue",
	createAt: "2017-01-06 12:00:00",
	updateAt: "2017-01-06 12:00:00"
};

AppSetting.create(option, function(err, result){
    if(err){
        console.log(err);
        return
    }

    console.log(result);
})




















